package cn.edu.scau.cmi.maikejian.abstractFactory.factory;


import cn.edu.scau.cmi.maikejian.abstractFactory.domainAbstractClass.Meat;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;

public class Controller {

    @FXML
    private Button product;
    @FXML
    private ComboBox<String> ChooseBrand;
    @FXML
    private ComboBox<String> ChooseMeat;
    @FXML
    private TextArea textarea;

    public void initialize() {
    
        ChooseBrand.getItems().removeAll(ChooseBrand.getItems());
        ChooseBrand.getItems().addAll("Wens","Tianbang","Aonong");
    	ChooseBrand.getSelectionModel().select(0);
    	ChooseMeat.getItems().removeAll(ChooseMeat.getItems());
    	ChooseMeat.getItems().addAll("Beef","Pork","Chicken");
    	ChooseMeat.getSelectionModel().select(0);
    }
    

    @FXML
    void Product(ActionEvent event) {
        String brand = ChooseBrand.getSelectionModel().getSelectedItem().toString();
        String meat = ChooseMeat.getSelectionModel().getSelectedItem().toString();
    	AbstractFactory abstractFactory = AbstractFactory.getFactory(brand);
    	Meat m = null;
    	switch (meat) {
		case "Beef":
			  m = abstractFactory.createBeef();
			break;
        case "Pork":
        	  m = abstractFactory.createPork();
        	  break;
        case "Chicken":
              m = abstractFactory.createChicken();
              break;
		default:
			break;
		}
    	textarea.appendText(m.show()
    			+"\n");
    }

}
